#include "relay.h"
#include "stdint.h"
//#include "CH58x_gpio.h"
#include "CH58x_common.h"
static uint8_t Relay_Status=0;
#define RELAYCLOSE 0
#define RELAYOPEN  1
void Relay_Init(void)
{
   GPIOB_ModeCfg(Relay_Pin, GPIO_ModeOut_PP_20mA);
   Relay_Status=RELAYCLOSE;
   SetRelayLevel(RELAYCLOSE);
}

static void RelaySetHighLevel(void)
{
   GPIOB_SetBits(Relay_Pin);
   Relay_Status=RELAYCLOSE ;
}

static void RelaySetLowLevel(void)
{
   GPIOB_ResetBits(Relay_Pin);
   Relay_Status=RELAYOPEN;
}

void SetRelayLevel(bool PinLevel)
{
    (PinLevel == true) ? RelaySetLowLevel():  RelaySetHighLevel();
}

bool Get_Relay_Status(void)
{
   return Relay_Status;
}
